<template>
	<div class="category">
		<!-- 切换的点击区域 -->
		<ul class="title-ul">
			<!-- 当点击事件的时候：标题的默认效果切换，选项卡之间有人需要切换 -->
			<li :class="{'default': iscur===item.id}" @click="iscur=item.id" v-for="item in tabs " :key="item.id">
				{{item.name}}
				<span class="default-span"></span>
			</li>
		</ul>
		<CategoryTab1 :propcategory1='list' v-if='iscur===1' :propcatetab1="propcategory"></CategoryTab1>
		<CategoryTab2 :propcategory2='list2' v-if='iscur===2' :propcatetab2="list2"></CategoryTab2>
	</div>
</template>

<script>
	import CategoryTab1 from './CategoryTab1.vue'
	import CategoryTab2 from './CategoryTab2.vue'
	export default{
		name:'Category',
		components:{
			CategoryTab1,
			CategoryTab2
		},
		data(){
			return{
				list:[],
				list2:[],
				tabs:[
					{id:1,name:'热门度假'},
					{id:2,name:'热门景点'}
				],
				iscur:1 
			}
		},
		props:['propcategory'],
		watch:{
			propcategory(){
				this.list=this.propcategory
				this.list2=this.propcategory.tabList
			}
		}
	}
</script>

<style scoped>
	.category{
		width: 90%;
		margin: 0.5rem auto;
		height: 10rem;
	}
	.category .title-ul{
		height: 1.17rem;
		background-color: #eeeeee;
		width: 100%;
		border-radius: 0.3rem;
		display: flex;
		align-items: center;
	}
	.category .title-ul li{
		width: 50%;
		text-align: center;
		line-height: 1.17rem;
		font-size: .35rem;
		font-weight: bold;
		border-radius: 0.3rem;
		position: relative;
	}
	.category .title-ul .default{
		background-color: white;
	}
	.category .title-ul .default .default-span{
		background-color: gold;
		display: block;
		height: 0.1rem;
		width: 1rem;
		position: absolute;
		left: 39%;
		bottom: 18%;
	}
</style>
